feat: Add afterEventEnqueue hook execution for event enqueueing #134
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requirements
Related issues
This PR introduces a new
afterEventEnqueuehook that allows developers to observe when events are enqueued for processing in the LaunchDarkly SDK.Describe the solution you've provided
New Feature: afterEventEnqueue Hook
This PR introduces a complete implementation of the
afterEventEnqueuehook functionality, allowing developers to hook into the event enqueuing process for monitoring, analytics, and debugging purposes.Implementation Details
1. Hook Runner Implementation (
HookRunner.js)AFTER_ENQUEUE_STAGE_NAMEconstant for consistent stage namingexecuteAfterEnqueue()function that executes hooks in reverse order (consistent with other "after" hooks)afterEventEnqueue()method to the HookRunner interface with proper empty hooks handlingtryExecuteStage()for robust exception handling2. SDK Integration (
index.js)enqueueEvent()function:hookRunner.afterEventEnqueue(event)3. TypeScript Type Definitions (
typings.d.ts)EventEnqueueContextinterface with comprehensive typing for all event types:identifyevents: context, creationDatefeatureevents: key, context, value, variation, version, default, reason, trackEvents, debugEventsUntilDatecustomevents: key, context, data, metricValue, url, contextKind, creationDatedebugevents: all feature event propertiesHookinterface to includeafterEventEnqueue?(hookContext: EventEnqueueContext): voidUsage Example
Additional context
This new hook provides developers with observability into the SDK's event processing pipeline. It's particularly useful for: